package com.example.bookstore.security

import com.example.bookstore.entity.UserEntity
import org.springframework.security.core.GrantedAuthority
import org.springframework.security.core.userdetails.User
import java.io.Serializable

/**
 * Created by IntelliJ IDEA.
 * User: lvshe
 * Date: 2019/8/13
 * Time: 19:13
 */
class JwtUser : User, Serializable {

    constructor(username: String?, password: String?, authorities: MutableCollection<out GrantedAuthority>?) : super(username, password, authorities)
    constructor(username: String?, password: String?, enabled: Boolean, accountNonExpired: Boolean, credentialsNonExpired: Boolean, accountNonLocked: Boolean, authorities: MutableCollection<out GrantedAuthority>?) : super(username, password, enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, authorities)

    companion object {
        fun createJwtUser(user: UserEntity): JwtUser {
            return JwtUser(user.email, user.password, mutableListOf())
        }
    }

}